package cn.cs.service;

import cn.cs.mapper.InvoiceMapper;
import cn.cs.pojo.Invoice;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
public class RestInvoiceService {

    @Resource
    private InvoiceMapper invoiceMapper;


    @RequestMapping(value = "/getInvoiceById", method = RequestMethod.POST)
    public Invoice getInvoiceById(@RequestParam("id") String id)throws Exception{
        return invoiceMapper.getInvoiceById(id);
    }

    @RequestMapping(value = "/getInvoiceListByUserId", method = RequestMethod.POST)
    public List<Invoice>	getInvoiceListByUserId(@RequestParam("userId") String userId, @RequestParam("userPid") String userPid)throws Exception{
        return invoiceMapper.getInvoiceListByUserId(userId, userPid);
    }

    @RequestMapping(value = "/getInvoiceCountByMap", method = RequestMethod.POST)
    public Integer getInvoiceCountByMap(@RequestBody Map<String, Object> param)throws Exception{
        return invoiceMapper.getInvoiceCountByMap(param);
    }

    @RequestMapping(value = "/getInvoiceListByMap", method = RequestMethod.POST)
    public List<Invoice> getInvoiceListByMap(@RequestBody Map<String, Object> param)throws Exception{
        return invoiceMapper.getInvoiceListByMap(param);
    }

    @RequestMapping(value = "/addInvoice", method = RequestMethod.POST)
    public Integer addInvoice(@RequestBody Invoice invoice)throws Exception{
        return invoiceMapper.insertInvoice(invoice);
    }

    @RequestMapping(value = "/modifyInvoice", method = RequestMethod.POST)
    public Integer modifyInvoice(@RequestBody Invoice invoice)throws Exception{
        return invoiceMapper.updateInvoice(invoice);
    }

    @RequestMapping(value = "/deleteInvoiceById", method = RequestMethod.POST)
    public Integer deleteInvoiceById(@RequestParam("id") Long id)throws Exception{
        return invoiceMapper.deleteInvoiceById(id);
    }

    @RequestMapping(value = "/updateAccountDetailByIds", method = RequestMethod.POST)
    public Integer updateAccountDetailByIds(@RequestBody String[] ids)throws Exception{
        return invoiceMapper.updateAccountDetailByIds(ids);
    }




}
